#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
##############################################################################
#
#
#         ___           ___           ___           ___
#        /  /\         /  /\         /  /\         /  /\
#       /  /::\       /  /:/_       /  /:/_       /  /::\
#      /  /:/\:\     /  /:/ /\     /  /:/ /\     /  /:/\:\
#     /  /:/~/:/    /  /:/ /:/_   /  /:/ /::\   /  /:/~/:/
#    /__/:/ /:/___ /__/:/ /:/ /\ /__/:/ /:/\:\ /__/:/ /:/
#    \  \:\/:::::/ \  \:\/:/ /:/ \  \:\/:/~/:/ \  \:\/:/
#     \  \::/~~~~   \  \::/ /:/   \  \::/ /:/   \  \::/
#      \  \:\        \  \:\/:/     \__\/ /:/     \  \:\
#       \  \:\        \  \::/        /__/:/       \  \:\
#        \__\/         \__\/         \__\/         \__\/
#
#
#
#
#   This file is part of ReSP.
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#
#
#   (c) Giovanni Beltrame, Luca Fossati
#       Giovanni.Beltrame@esa.int fossati@elet.polimi.it
#
##############################################################################


import os

def build(bld):
    obj = bld.new_task_gen('cxx', 'cshlib')
    obj.source="""
        instructions.cpp
        registers.cpp
        alias.cpp
        processor.cpp
        interface.cpp
        decoder.cpp
        memory.cpp
        externalPorts.cpp
    """
    obj.uselib = 'BOOST BOOST_FILESYSTEM BOOST_THREAD SYSTEMC_H TLM TRAP'
    obj.uselib_local = 'systemc binutils utils'
    obj.includes = '.'
    obj.name = 'arm9tdmi_funcLT'
    obj.target = 'arm9tdmi_funcLT'

    obj = bld.new_task_gen('pypp')
    obj.source="""
        processor.hpp
        memory.hpp
    """
    obj.uselib = 'BOOST BOOST_FILESYSTEM BOOST_THREAD SYSTEMC_H TLM TRAP BOOST_PYTHON'
    obj.uselib_local = 'systemc arm9tdmi_funcLT binutils'
    obj.includes = '.'
    obj.split = 10
    obj.name = 'arm9tdmi_funcLT_wrapper'
    obj.target = 'arm9tdmi_funcLT_wrapper'
    obj.include = 'scwrapper tlmwrapper trapwrapper'
    obj.start_decls = 'arm9tdmi_funclt_trap'
    obj.custom_code = """
for i in mb.global_ns.classes():
    for base in i.recursive_bases:
        if base.related_class.name == 'Instruction':
            i.exclude()
            break
mb.global_ns.class_('Instruction').exclude()
mb.global_ns.class_('ARM9TDMI_ABIIf').constructors().exclude()

mb.global_ns.class_('Register').exclude()
mb.global_ns.class_('Register').ignore = False
mb.global_ns.class_('Alias').exclude()
mb.global_ns.class_('Alias').ignore = False
mb.global_ns.class_('InnerField').exclude()
mb.global_ns.class_('InnerField').ignore = False
mb.global_ns.class_('Processor_arm9tdmi_funclt').member_function('decode').exclude()
mb.global_ns.class_('Processor_arm9tdmi_funclt').member_function('getInterface').call_policies = call_policies.return_value_policy( call_policies.reference_existing_object )
"""
